package com.bosssoft.cart.service.impl;

import com.bosssoft.cart.mapper.BookMapper;
import com.bosssoft.cart.pojo.Books;
import com.bosssoft.cart.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;

    /**
     * 添加商品
     * @param books 商品
     */
    @Override
    public int addBook(Books books) {
        bookMapper.addBook(books);
        return 0;
    }

    /**
     * 根据id删除商品
     * @param id 商品id
     */
    @Override
    public int deleteBookById(int id) {
        bookMapper.deleteBookById(id);
        return 0;
    }

    /**
     * 更新商品
     * @param books 商品books
     */
    @Override
    public int uodateBook(Books books) {
        bookMapper.uodateBook(books);
        return 0;
    }

    /**
     * 根据id获取商品
     * @param bookID 商品id
     * @return 商品
     */
    @Override
    public Books queryBookById(int bookID) {
        return bookMapper.queryBookById(bookID);
    }

    /**
     * 获取商品列表
     * @return 商品列表
     */
    @Override
    public List<Books> queryAllBook() {
        return bookMapper.queryAllBook();
    }

    /**
     * 根据bookName获取商品
     * @param bookName 商品名称
     * @return 商品列表
     */
    @Override
    public List<Books> queryBookByName(String bookName) {
        return bookMapper.queryBookByName(bookName);
    }
}
